<template>
  <div class="app-container">
     <div class="fromDiv">
      <span>个人入会表单设置</span>
    </div>
  
    <div class="configDiv">
  <el-form :model="form" status-icon :rules="rules" ref="form" label-width="105px">
  <el-form-item label="申请开关" prop="pass">
    <el-switch  v-model="form.personalStatus"
                :active-value="1"
                :inactive-value="0"
                @change="handleStatusChange(form)"></el-switch>
  </el-form-item>
  <el-form-item label="您的姓名" prop="checkPass">
    <el-input type="text" v-model="form.iconUrl" :disabled="true" ></el-input>
  </el-form-item>
  <el-form-item label="联系电话" prop="age">
    <el-input type="text" v-model.number="form.personnelName" :disabled="true"></el-input>
  </el-form-item>
  <el-form-item label="您的性别">
    <el-radio v-model="radio" label="1">男</el-radio>
  <el-radio v-model="radio" label="2">女</el-radio>
  </el-form-item>
  <el-row :gutter="20" v-for="(item,index) in wxconfigList" :key="index">
  <el-form-item  v-if="item.type=='picker'" :label="item.name">
    <el-select v-model="value" placeholder="请选择">
    <el-option
      v-for="val in item.data"
      :key="val.value"
      :label="val.label"
      :value="val.value">
    </el-option>
  </el-select>
  </el-form-item>
  </el-row>
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>

    </div>

  </div>
</template>

<script>
import { listActivityCustom, getActivityCustom, delActivityCustom, addActivityCustom, updateActivityCustom } from "@/api/activity/activityCustom";
export default {
  name: "Wxconfig",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 微信小程序配置表格数据
      wxconfigList: [],
      // 弹出层标题
      title: "",
      value:'',
      radio:'',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        asId: null,
        sourceType:2
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        wechatType: [
          { required: true, message: "公众号类型：1服务号，2订阅号不能为空", trigger: "change" }
        ],
        asId: [
          { required: true, message: "协会id不能为空", trigger: "blur" }
        ],
        officeName: [
          { required: true, message: "移动办公名称不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询微信小程序配置列表 */
    getList() {
      this.loading = true;
      listActivityCustom(this.queryParams).then(res => {
        console.info(res);
        this.wxconfigList = res.rows;
        this.form.personalStatus=res.status;
        this.total = res.total;
        this.loading = false;
      });
    },

    handleStatusChange(form){
      console.info(form);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        wechatType: null,
        asId: null,
        appId: null,
        appSecret: null,
        color: null,
        codeUrl: null,
        iconUrl: null,
        pageTitle: null,
        asTitle: null,
        asDesc: null,
        duesRemark: null,
        officeName: null,
        contactsStatus: 0,
        personalStatus: null,
        groupStatus: 0,
        companyStatus: 0,
        fileUrlOne: null,
        fileUrlTwo: null,
        fileUrlThree: null,
        memberName: null,
        memberRemark: null,
        companyRemark: null,
        groupRemark: null,
        posterSwitch: null,
        storeSwitch: null,
        shopLink: null,
        contactsVisible: null,
        contactsVisibleJoin: null,
        parentId: null,
        leaderName: null,
        personnelName: null,
        createTime: null,
        updateTime: null,
        status: 0,
        sex:null,
        customerUrl: null,
        applyTip: null,
        applyPersonTip: null,
        applyCompanyTip: null,
        applyGroupTip: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加微信小程序配置";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getWxconfig(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改微信小程序配置";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateWxconfig(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addWxconfig(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除微信小程序配置编号为"' + ids + '"的数据项？').then(function() {
        return delWxconfig(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('allocation/wxconfig/export', {
        ...this.queryParams
      }, `wxconfig_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style>

.fromDiv{
   height: 30px;
  box-shadow: 0 2px 40px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
  text-align: center;
  line-height: 30px;
  margin: 10px 0px 20px 0px;
  background-color: aqua;
}
.configDiv{
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
